A program executed in an information processor operates while using one or more devices (peripheral devices) of the information processor. Thus, a program produced on the premise of a specific information processor does not normally operate if a device to be processed does not exist or a control method and/or specification differs even though the same type of device as the one to be process exists. In such cases, this program can be used in an information processor different from the specific information processor if the device to be processed can be emulated without changing the program.
Generally, control registers of devices are arranged in an address space of a central processing unit (CPU) and a targeted device operates through the operation of the control register by the CPU. In other words, the CPU writes or reads information to or from an address of the control register of the targeted device. Accordingly, upon emulating the device using software, access to a specific address, i.e. the address of the control register of the device to be emulated from the CPU needs to be trapped. The device to be emulated is a device which is to be processed by the software, but does not actually exist.
A general method for trapping an access to a specific address uses a protection function of a memory space. In other words, an exception is generated at the time of an access to a trapped address by prohibiting reading from and writing to this address. By starting emulation upon an exception handler and returning to an initial program after the completion of the emulation, the device can be emulated without changing this program.
There is also a bus monitoring device for detecting an access to a specific address space from a CPU by monitoring signals flowing on a bus (see, for example, patent literature 1). The bus monitoring device monitors various signals flowing on the bus and causes the CPU to interrupt if a signal conforming to a set condition is detected. Thus, an access to a specific address from the CPU can be trapped.
A device is emulated by letting software perform a process, which is supposed to be performed by the device to be emulated, instead of the device. In order to let the software perform the process instead, it is necessary to know the access, i.e. to obtain the content of the access after the access to a control register of the targeted device is trapped. For example, if a device to be emulated is a DMA (Direct Memory Access) and a process to be performed by the device is a memory copy, software for emulation obtains information necessary for the process such as an address of data to be copied in the memory. Hereinafter, the control register of the device to be emulated is referred to as a “virtual register”.
In the case of an access to the virtual register for data writing, the software for emulation analyzes the content of a trapped command (write command) and specifies an arithmetic register holding data to be written. Further, the software for emulation obtains the data from the specified arithmetic register and writes the obtained data to the targeted address.
In the case of an access to the virtual register for data reading, the software for emulation analyzes the content of a trapped command (read command) and specifies the destination of the read data (arithmetic register, memory, or the like). Further, the software for emulation stores the read data in the destination.
However, in the conventional technology, the software for emulation analyzes the content of a trapped access and obtains necessary data every time an access to the control register is trapped. This means the execution of a plurality of commands and, hence, there has been a problem of increasing throughput.